package UnitTest;

import org.junit.Test;

import common.util.EmailValidator;
import common.util.ValidateUtil;

import static org.junit.Assert.assertEquals;

public class utilUnitTest {
	
	ValidateUtil V =new ValidateUtil();
	private static EmailValidator emV = new EmailValidator();
		
	@Test
	public void validateEmailStandard1() {
		boolean kq = emV.validate("@");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard2() {
		boolean kq = emV.validate("abc@");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard3() {
		boolean kq = emV.validate("abc@abc");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard4() {
		boolean kq = emV.validate("abc@abc.abc");
		assertEquals(true, kq);
	}
	@Test
	public void validateEmailStandard5() {
		boolean kq = emV.validate("abc.@abc.abc");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard6() {
		boolean kq = emV.validate(".abc@abc.abc");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard7() {
		boolean kq = emV.validate("abc@.abc.abc");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard8() {
		boolean kq = emV.validate("abc@abc.abc.");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard9() {
		boolean kq = emV.validate("abc@abc..abc");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard10() {
		boolean kq = emV.validate(" ");
		assertEquals(false, kq);
	}
	@Test
	public void validateEmailStandard11() {
		boolean kq = emV.validate("nguyenphuquangk15t1@gmail.com");
		assertEquals(true, kq);
	}
	// ============================================
	// BR.01.30 Address isn�t empty.
	// BR.01.32 District isn't empty.
	// BR.01.33 City isn't empty.
	// BR.01.34 Phone number isn�t empty.
	// BR.01.36 Company name isn�t empty.
	// BR.01.38 Tax ID isn�t empty.
	// BR.01.Business domain isn�t empty.40
	@Test
	public void validateEmptyString1() {
		boolean kq = ValidateUtil.validateEmptyString("");
		assertEquals(true, kq);
	}
	@Test
	public void validateEmptyString2() {
		boolean kq = ValidateUtil.validateEmptyString("  ");
		assertEquals(true, kq);
	}
	@Test
	public void validateEmptyString3() {
		boolean kq = ValidateUtil.validateEmptyString("abc");
		assertEquals(false, kq);
	}

	// ============================================
	// BR.01.37 Length of company name isn�t from 6 to 200 characters.
	@Test	
	public void validateLengthOfCompanyName1() {
	boolean kq = ValidateUtil.validateLengthOfCompanyName("abc");
	 assertEquals(false, kq);
	}
	@Test	
	 public void validateLengthOfCompanyName2() {
	 boolean kq = ValidateUtil.validateLengthOfCompanyName(" ");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfCompanyName3() {
	 boolean kq = ValidateUtil.validateLengthOfCompanyName("");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfCompanyName4() {
	 boolean kq = ValidateUtil.validateLengthOfCompanyName("abcxyz");
	 assertEquals(true, kq);
	 }

	// ============================================
	// BR.01.39 Length of tax ID is from 6 to 50 characters.
	@Test
	 public void validateLengthOfTaxID1() {
	 boolean kq = ValidateUtil.validateLengthOfTaxID("");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfTaxID2() {
	 boolean kq = ValidateUtil.validateLengthOfTaxID("  ");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfTaxID3() {
	 boolean kq = ValidateUtil.validateLengthOfTaxID("abc");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfTaxID4() {
	 boolean kq = ValidateUtil.validateLengthOfTaxID("abcxyz");
	 assertEquals(true, kq);
	 }

	// ============================================
	// BR.01.41 Length of business domain is from 6 to 50 characters.
	@Test
	 public void validateLengthOfBusinessDomain1() {
	 boolean kq = ValidateUtil.validateLengthOfBusinessDomain("");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfBusinessDomain2() {
	 boolean kq = ValidateUtil.validateLengthOfBusinessDomain("  ");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfBusinessDomain3() {
	 boolean kq = ValidateUtil.validateLengthOfBusinessDomain("abc");
	 assertEquals(false, kq);
	 }
	@Test
	 public void validateLengthOfBusinessDomain4() {
	 boolean kq = ValidateUtil.validateLengthOfBusinessDomain("abcxyz");
	 assertEquals(true, kq);
	 }
	// ============================================
	// ============================================Edit Account Profile
		// ===================
		// -----họ tên không được để trống---------
		//------- dung lai test case validateEmptyString1 o tren

		@Test
		public void validateEmptyString4() {
			boolean kq = ValidateUtil.validateEmptyString("abc@abc.abc");
			assertEquals(false, kq);
		}

		// ---------giới tính không được để trống ----------
		@Test
		public void validateEmptyString5() {
			boolean kq = ValidateUtil.validateEmptyString("");
			assertEquals(true, kq);
		}

		@Test
		public void validateEmptyString6() {
			boolean kq = ValidateUtil.validateEmptyString("Nữ");
			assertEquals(false, kq);
		}

		// ------------------địa chỉ không được để trống------------------------
		@Test
		public void validateEmptyString7() {
			boolean kq = ValidateUtil.validateEmptyString("");
			assertEquals(true, kq);
		}

		@Test
		public void validateEmptyString8() {
			boolean kq = ValidateUtil.validateEmptyString("45 Nguyễn Khắc Nhu");
			assertEquals(false, kq);
		}

		// ---------------số điện thoại không được để trống -------------------
		@Test
		public void validateEmptyString9() {
			boolean kq = ValidateUtil.validateEmptyString("");
			assertEquals(true, kq);
		}

		@Test
		public void validateEmptyString10() {
			boolean kq = ValidateUtil.validateEmptyString("01234567899");
			assertEquals(false, kq);
		}

		// -----Chiều dài họ tên từ 6 đến 50 ký tự--------
		@Test
		public void validateLengthOfFullname1() {
			boolean kq = ValidateUtil.validateLengthOfFullname("");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfFullname2() {
			boolean kq = ValidateUtil.validateLengthOfFullname("abc");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfFullname3() {
			boolean kq = ValidateUtil
					.validateLengthOfFullname("abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfFullname4() {
			boolean kq = ValidateUtil.validateLengthOfFullname("abcdef");
			assertEquals(true, kq);
		}

		// ---------Chiều dài của địa chỉ từ 10 đến 100 ký tự -------------
		@Test
		public void validateLengthOfAddress1() {
			boolean kq = ValidateUtil.validateLengthOfAddress("");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfAddress2() {
			boolean kq = ValidateUtil.validateLengthOfAddress("abc");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfAddress3() {
			boolean kq = ValidateUtil
					.validateLengthOfAddress("1234567890 abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij abcdefghij");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfAddress4() {
			boolean kq = ValidateUtil.validateLengthOfAddress("45 nguyễn khắc nhu");
			assertEquals(true, kq);
		}

		// ------------------Chiều dài số điện thoại từ 10 đến 20 ký
		// tự------------------------
		@Test
		public void validateLengthOfPhoneNumber1() {
			boolean kq = ValidateUtil.validateLengthOfPhoneNumber("");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfPhoneNumber2() {
			boolean kq = ValidateUtil.validateLengthOfPhoneNumber("123");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfPhoneNumber3() {
			boolean kq = ValidateUtil
					.validateLengthOfPhoneNumber("123456789012345678901234567890");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfPhoneNumber4() {
			boolean kq = ValidateUtil.validateLengthOfPhoneNumber("01234567899");
			assertEquals(true, kq);
		}

		// ------------Email phải theo chuẩn (edit account profile - retrieve
		// password)-----------
		// -------------Email không nối với User ID ---------------------
		/*@Test
		public void validateEmailMatchUserID10() {
			boolean kq = ValidateUtil.validateEmailMatchUserID("", "");
			assertEquals(false, kq);
		}

		@Test
		public void validateEmailMatchUserID11() {
			boolean kq = ValidateUtil.validateEmailMatchUserID("u00006", "");
			assertEquals(false, kq);
		}

		@Test
		public void validateEmailMatchUserID12() {
			boolean kq = ValidateUtil.validateEmailMatchUserID("u00006",
					"duonghoaikhanh@gmail.com");
			assertEquals(false, kq);
		}*/

		// ============================== Retrieve password =============
		// ---------------User ID không được để trống -------------------
		@Test
		public void validateEmptyString11() {
			boolean kq = ValidateUtil.validateEmptyString("");
			assertEquals(true, kq);
		}

		@Test
		public void validateEmptyString12() {
			boolean kq = ValidateUtil.validateEmptyString("u00001");
			assertEquals(false, kq);
		}

		// ----------------Chiều dài user ID từ 6 đến 25 ký tự ----------
		@Test
		public void validateLengthOfUserID1() {
			boolean kq = ValidateUtil.validateLengthOfUserID("");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfUserID2() {
			boolean kq = ValidateUtil.validateLengthOfUserID("abc");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfUserID3() {
			boolean kq = ValidateUtil
					.validateLengthOfUserID("abcdefghij abcdefghij abcdefghij");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfUserID4() {
			boolean kq = ValidateUtil.validateLengthOfUserID("abcdef");
			assertEquals(true, kq);
		}

		// -------------Email không nối với User ID ---------------------
		/*@Test
		public void validateEmailMatchUserID1() {
			boolean kq = ValidateUtil.validateEmailMatchUserID("", "");
			assertEquals(false, kq);
		}

		@Test
		public void validateEmailMatchUserID2() {
			boolean kq = ValidateUtil.validateEmailMatchUserID("u00006", "");
			assertEquals(false, kq);
		}

		@Test
		public void validateEmailMatchUserID3() {
			boolean kq = ValidateUtil.validateEmailMatchUserID("u00006",
					"duonghoaikhanh@gmail.com");
			assertEquals(false, kq);
		}

		@Test
		public void validateEmailMatchUserID4() {
			boolean kq = ValidateUtil.validateEmailMatchUserID("u00006",
					"anhton6@gmail.com");
			assertEquals(true, kq);
		}*/

		// --------------password tạm không đúng--------------
		// --------------Mật khẩu không được để trống-----------------
		@Test
		public void validateEmptyString13() {
			boolean kq = ValidateUtil.validateEmptyString("");
			assertEquals(true, kq);
		}

		@Test
		public void validateEmptyString14() {
			boolean kq = ValidateUtil.validateEmptyString("123456");
			assertEquals(false, kq);
		}

		// --------------xác nhận lại mật khẩu không được để trống----------
		public void validateEmptyString15() {
			boolean kq = ValidateUtil.validateEmptyString("");
			assertEquals(false, kq);
		}

		@Test
		public void validateEmptyString16() {
			boolean kq = ValidateUtil.validateEmptyString("123456");
			assertEquals(false, kq);
		}

		// -------------Chiều dài mật khẩu từ 6-50 ký tự--------------------
		@Test
		public void validateLengthOfPassword1() {
			boolean kq = ValidateUtil.validateLengthOfPassword("");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfPassword2() {
			boolean kq = ValidateUtil.validateLengthOfPassword("123");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfPassword3() {
			boolean kq = ValidateUtil
					.validateLengthOfPassword("1234567890 1234567890 1234567890 1234567890 1234567890 1234567890");
			assertEquals(false, kq);
		}

		@Test
		public void validateLengthOfPassword4() {
			boolean kq = ValidateUtil.validateLengthOfPassword("123456");
			assertEquals(true, kq);
		}

		// -------------Mật khẩu và xác nhận mật khẩu không đúng---------------------
		@Test
		public void validateConfirmPassword1() {
			boolean kq = ValidateUtil.validateConfirmPassword("", "");
			assertEquals(true, kq);
		}

		@Test
		public void validateConfirmPassword2() {
			boolean kq = ValidateUtil.validateConfirmPassword("123456", "");
			assertEquals(false, kq);
		}

		@Test
		public void validateConfirmPassword3() {
			boolean kq = ValidateUtil.validateConfirmPassword("123456", "abcdef");
			assertEquals(false, kq);
		}

		@Test
		public void validateConfirmPassword4() {
			boolean kq = ValidateUtil.validateConfirmPassword("123456", "123456");
			assertEquals(true, kq);
		}
		
		@Test
		public void validateNameStandard1() {
			boolean kq = ValidateUtil.validateNameStandard("mrquang1009");
			assertEquals(true, kq);
		}
		@Test
		public void validateNameStandard2() {
			boolean kq = ValidateUtil.validateNameStandard("*&^%$#$%");
			assertEquals(false, kq);
		}
		@Test
		public void validateNameStandard3() {
			boolean kq = ValidateUtil.validateNameStandard("^^^^^^");
			assertEquals(false, kq);
		}
		@Test
		public void validateNameStandard4() {
			boolean kq = ValidateUtil.validateNameStandard("$$$$");
			assertEquals(false, kq);
		}
		@Test
		public void validateNameStandard5() {
			boolean kq = ValidateUtil.validateNameStandard("");
			assertEquals(false, kq);
		}
		@Test
		public void validateNameStandard6() {
			boolean kq = ValidateUtil.validateNameStandard("   ");
			assertEquals(false, kq);
		}
}
